package top.zhangjianyong.tools.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.zhangjianyong.tools.entity.TransactionOrder;
import top.zhangjianyong.tools.parm.TransactionOrderAddParm;
import top.zhangjianyong.tools.parm.TransactionOrderPageParm;
import top.zhangjianyong.tools.parm.TransactionOrderUpdateParm;
import top.zhangjianyong.tools.service.api.TransactionOrderService;
import top.zhangjianyong.tools.utils.ApiResponse;

/**
 * @author ： zhangjianyong
 * @date ： 2022/4/25 上午9:34
 */
@RestController
@RequestMapping("/transactionOrder")
public class TransactionOrderController {

    @Autowired
    private TransactionOrderService transactionOrderService;

    @PostMapping("/add")
    public ApiResponse add(@RequestBody TransactionOrderAddParm transactionOrderAddParm) {
        return transactionOrderService.add(transactionOrderAddParm);
    }

    @PostMapping("/update/{id}")
    public ApiResponse update(@PathVariable Long id,
                              @RequestBody TransactionOrderUpdateParm transactionOrderUpdateParm) {
        return transactionOrderService.update(id, transactionOrderUpdateParm);
    }

    @PostMapping("/page/{page}/{size}")
    public ApiResponse page(@PathVariable("page") int page, @PathVariable("size") int size,
                            @RequestBody TransactionOrderPageParm transactionOrderPageParm) {
        return transactionOrderService.page(transactionOrderPageParm, page, size);
    }

}
